import { Component } from "react";
import {
  Button,
  Cell,
  Empty,
  Avatar,
  Grid,
  Image,
  Tabs,
} from "@nutui/nutui-react-taro";
import styles from "./index.scss";
import { useModel } from "@/store";
import Taro from "@tarojs/taro";
import { useState } from "react";
import { useEffect } from "react";
import { queryClinicChargePat } from "@/services/payment";
import { Loading } from "@nutui/icons-react-taro";
import NoData from "@/components/NoData";
export default () => {
  const { curPatientInfo } = useModel("patient");
  const [list, setList] = useState([]);
  const [loading, setLoading] = useState(false);
  //   queryType	查询方式	字符串	1	否	1：病人标识号2：医保个人编号
  // queryNo	查询号	字符串	20	否
  useEffect(() => {
    getList();
  }, []);

  const getList = () => {
    setLoading(true);
    queryClinicChargePat({
      queryType: "1",
      queryNo: curPatientInfo.patientId,
      // queryNo:'01660255'
    })
      .then((res) => {
        setList(res);
      })
      .finally(() => {
        setLoading(false);
      });
  };

  return (
    <view className={styles.notPaymentListWarp}>
      {loading && <Loading type="circular" />}
      {list.map((item) => {
        return (
          <view
            key={item.visitSerialNo}
            className={styles.paymentCard}
            onClick={() => {
              Taro.navigateTo({
                url: `/pages/payment/paymentDetail/index?visitSerialNo=${item.visitSerialNo}&visitDoctor=${item.visitDoctor}&visitDept=${item.visitDept}&visitDate=${item.visitDate}&totalCosts=${item.totalCosts}`,
              });
            }}
          >
            <view className={styles.content}>
              <view className={styles.text}>
                就诊科室：{item.visitDeptName}
              </view>
              <view className={styles.text}>就诊时间：{item.visitDate}</view>
            </view>
            <view className={styles.bottom}>
              <view className={styles.price}>￥{item.totalCosts}</view>
              <view className={styles.action}> 去支付{">"}</view>
            </view>
          </view>
        );
      })}

      {!loading && list?.length === 0 && <view style={{height:'70vh'}}><NoData></NoData></view> }
    </view>
  );
};
